<!-- 查看城市-->
<script lang='ts' setup>
import { ref } from 'vue';

const navArray = [
    { url: new URL('../assets/publicCityIcon/a1.png', import.meta.url).href, text: '景点' },
    { url: new URL('../assets/publicCityIcon/a2.png', import.meta.url).href, text: '住宿' },
    { url: new URL('../assets/publicCityIcon/a3.png', import.meta.url).href, text: '美食' },
    { url: new URL('../assets/publicCityIcon/a4.png', import.meta.url).href, text: '购物' },
    { url: new URL('../assets/publicCityIcon/a5.png', import.meta.url).href, text: '游记' },
    { url: new URL('../assets/publicCityIcon/a6.png', import.meta.url).href, text: '旅游度假' },
]
const guidePhoto_one = [
    { url: new URL('../assets/publicCityIcon/cityPhoto/c1.jpg', import.meta.url).href, title: '北京环球度假村', text: '大片世界，在此成真', },
    { url: new URL('../assets/publicCityIcon/cityPhoto/c2.jpg', import.meta.url).href, title: '故宫', text: '穿越明清两朝的皇家宫殿群', },
    { url: new URL('../assets/publicCityIcon/cityPhoto/c3.jpg', import.meta.url).href, title: '八达岭长城', text: '不到长城非好汉', },

]
const guidePhoto_two = [
    { url: new URL('../assets/publicCityIcon/cityPhoto/c4.jpg', import.meta.url).href, title: '颐和园', text: '走入清朝皇帝的皇家园林', },
    { url: new URL('../assets/publicCityIcon/cityPhoto/c5.jpg', import.meta.url).href, title: '恭王府', text: '旧时清朝大臣和珅的王府', },
    { url: new URL('../assets/publicCityIcon/cityPhoto/c6.jpg', import.meta.url).href, title: '北京野生动物园', text: '近距离观赏野生动物', },
]
const bw = new URL('../assets/publicCityIcon/bw.png', import.meta.url).href
const bc = new URL('../assets/publicCityIcon/bc.png', import.meta.url).href
const bg = new URL('../assets/publicCityIcon/bg.png', import.meta.url).href
let flag: any = null
const changePlay = (e: any, number: number) => {
    if (flag == null) {
        flag = document.querySelectorAll('.flag')
        as(e, number)
    } else {
        as(e, number)
    }
}
function as(e: any, number: number) {
    flag.forEach((a: any) => {
        a.classList.remove('guide-title-active')
        a.style.backgroundImage = `url('')`
    })
    e.target.classList.add('guide-title-active')
    switch (number) {
        case 1: e.target.style.backgroundImage = `url(${bw})`
            break;
        case 2: e.target.style.backgroundImage = `url(${bc})`
            break;
        case 3: e.target.style.backgroundImage = `url(${bg})`
            break;
        default: e.target.style.backgroundImage = `url(${bw})`
    }
}
</script>
<template>
    <div class="box">
        <div class="box_mains">
            <div class="head">
                <div class="head_name">
                    北京
                </div>
                <div class="head_name_two">
                    BEIJING
                </div>
            </div>
            <div class="nav_box">
                <div class="nav-item" v-for="item in navArray">
                    <img :src="item.url" class="nav-item-icon">
                    <div class="nav-item-text">{{ item.text }}</div>
                </div>
            </div>
            <div class="city_photo">
                <img src="../assets/beautyLife/b1.jpg" alt="" class="city_img">
            </div>
            <div class="guide">
                <div class="guide-title">
                    <p class="flag guide-title-active" @click="changePlay($event, 1)">
                        必玩</p>
                    <p class="flag" @click="changePlay($event, 2)">必吃</p>
                    <p class="flag" @click="changePlay($event, 3)">必逛</p>
                </div>
                <div class="guide-nav">
                    <a v-for="item in guidePhoto_one" class="guide-nav-item"
                        href="https://you.ctrip.com/sight/beijing1/2045497.html" target="_blank">
                        <div class="guide-nav-item-top">
                            <img :src="item.url" alt="">
                        </div>
                        <div class="guide-nav-item-bottom">
                            <p class="title">{{ item.title }}</p>
                            <p class="tag">
                                <span>4.6分</span>
                                <span>5051条点评</span>
                            </p>
                            <p class="txt">{{ item.text }}</p>
                        </div>
                    </a>
                </div>
                <div class="guide-nav">
                    <a v-for="item in guidePhoto_two" class="guide-nav-item"
                        href="https://you.ctrip.com/sight/beijing1/2045497.html" target="_blank">
                        <div class="guide-nav-item-top">
                            <img :src="item.url" alt="">
                        </div>
                        <div class="guide-nav-item-bottom">
                            <p class="title">{{ item.title }}</p>
                            <p class="tag">
                                <span>4.6分</span>
                                <span>5051条点评</span>
                            </p>
                            <p class="txt">{{ item.text }}</p>
                        </div>
                    </a>
                </div>
            </div>
        </div>
    </div>
</template>
<style lang='scss' scoped>
.box {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;

    .box_mains {
        display: flex;
        flex-direction: column;
        min-width: 1180px;
    }

}

.guide {
    margin-top: 23px;

    .guide-nav {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 20px;
        cursor: pointer;

        .guide-nav-item {
            flex: 1 1;
            display: block;
            width: 0;
            background-color: #fff;
            border-radius: 8px 8px 8px 8px;
            overflow: hidden;
            box-shadow: 0px 4px 16px 1px rgb(0 0 0 / 6%);
            height: 372px;
            margin-right: 20px;
            max-width: 32.33%;

            .guide-nav-item-top {
                height: 245px;
                width: 100%;
                background-repeat: no-repeat;
                background-size: cover;
                background-color: #ccc;
            }

            .guide-nav-item-bottom {
                padding: 20px 15px 0 20px;
            }
        }
    }

    .guide-title {
        color: #333333;
        height: 32px;
        font-size: 16px;
        font-weight: normal;
        letter-spacing: 0px;
        display: flex;
        margin-bottom: 20px;

        &>p {
            margin-right: 32px;
            height: 32px;
            display: flex;
            align-items: flex-end;
            cursor: pointer;
        }

        .guide-title-active {
            width: 48px;
            background-image: url('../assets/publicCityIcon/bw.png');
            background-repeat: no-repeat;
            background-size: cover;
            color: #333333;
            font-size: 18px;
            font-weight: 500;
            letter-spacing: 0px;
        }
    }
}

.city_photo {
    width: 100%;
    height: 440px;
    margin-top: 22px;
    border-radius: 12px;
    background-color: #e8e8e8;
    overflow: hidden;

    .city_img {
        width: 100%;
        border-radius: 12px;
    }
}

.head {
    display: flex;
    flex-direction: row;
    margin-top: 32px;

    .head_name {
        font-size: 30px;
        font-weight: 500;
        color: #333333;
    }

    .head_name_two {
        margin-left: 16px;
        font-size: 30px;
        font-weight: 500;
        color: #CCD6E5;
    }
}

.nav_box {
    margin-top: 22px;
    display: flex;
    flex-direction: row;

    .nav-item {
        display: flex;
        flex-direction: row;
        align-items: center;
        margin-right: 24px;
        cursor: pointer;

        .nav-item-icon {
            width: 24px;
            height: 24px;
        }

        .nav-item-text {
            margin-left: 2px;
            font-size: 20px;
            color: #333333;
        }
    }
}
</style>
